<?php
ifi$_GET['cmd']=='edit') {
	SQLvalidate($_GET['id']);

	//selecting record from comments table
	$db = new dbquery;
	$db->query("SELECT * FROM $conf[prefix]comments WHERE id=$_GET[id]") or $db->err(__FILE__, __LINE__);
	$d=$db->fetch_object();
	//

	if($d->who!=$_SESSION['id']) {
		redirect('index.php?module=error&amp;error=auth_error');
		exit;
	}

	$registered=true;
	if(!is_numeric($d->who))
		$registered=false;

	$d->text=read_text_edit($d->text);

	//edit_form
	$content=string_template(read_file('middle.php'), array('content'=>string_template(read_file('admin/themes/comments_edit_form.php'), array('theme_path'=>$GLOBALS['theme_path'], 'id'=>$d->id, 'text_content'=>$d->text, 'title_content'=>$d->title, 'function' => 'comment_edit')), 'theme_path'=>$GLOBALS['theme_path']));
	//
}
elseif($_GET['cmd']=='really_delete') {
	SQLvalidate($_GET['id']);
	$db = new dbquery;
	$db->query("SELECT * FROM $conf[prefix]comments WHERE id=$_GET[id]") or $db->err(__FILE__, __LINE__);

	$d=$db->fetch_object();

	if($d->who!=$_SESSION['id'] && !perms_check('comments', 'edit')) {
		redirect('index.php?module=error&amp;error=auth_error');
		exit;
	}

	$what=read_text_rest($d->title);
	$yes='<br /><input type="button" onClick="javascript:location.href=\'index.php?module=comments&amp;function=comment_delete&amp;id='.$_GET['id'].'&amp;whatid='.$d->whatid.'&amp;what='.$d->what.'\'" value="'.$lang['yes'].'" class="button">';
	$no='<input type="button" onClick="javascript:history.go(-1);" value="'.$lang['no'].'" class="button">';

	$content=string_template(read_file('middle.php'), array('content'=>string_template($lang['admin_really_delete'], array('what'=>$what, 'yes'=>$yes, 'no'=>$no)), 'theme_path'=>$GLOBALS['theme_path'], 'description'=>$lang['admin_delete']));
}

//generating menus (what, template)
$menu_left=menu('left', 'left');
$menu_right=menu('right', 'right');
$menu_top=menu('top', 'top');
//

//site_generation_time
$GLOBALS['time_end'] = microtime(1);
$site_generation_time=abs(round($GLOBALS['time_end']-$GLOBALS['time_start'], 3));
//

//creating template
//header
$tpl = new tpl;
$tpl->create('header.php', array('title' => $GLOBALS['lang']['global']['site_title'], 'description' => $GLOBALS['lang']['global']['site_description'], 'keywords' => $GLOBALS['lang']['global']['site_keywords'], 'theme_path'=>$GLOBALS['theme_path'], 'menu_top' => $menu_top));
//body
$tpl->create('body.php', array('theme_path' => $GLOBALS['theme_path'], 'menu_top' => $menu_top, 'menu_left' => $menu_left, 'menu_right' => $menu_right, 'content' => $content));
//footer
$tpl->create('footer.php', array('site_generation_time' => string_template($GLOBALS['lang']['global']['site_generation_time'], array('site_generation_time'=>$site_generation_time, 'queries'=>$db->query_count())), 'theme_path'=>$GLOBALS['theme_path'], 'copyright' => $GLOBALS['lang']['global']['site_copyright'], 'queries'=>$db->query_count()));
//parse
$tpl->parse();

?>
